package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"manage/models"
)

type RegisterController struct {
	beego.Controller
}

func (c *RegisterController) Register() {
	username := c.GetString("username")
	password := c.GetString("password")
	ss := models.Wster{
		Username: username,
		Password: username,
	}
	if username == "" || password == "" {
		res := Msg{
			Code: 0,
			Msg:  "账号或密码不能为空",
		}
		c.Data["json"] = res
		c.ServeJSON()
		return
	}
	if ss.Password != password {
		res := Msg{
			Code: 0,
			Msg:  "登陆失败密码错误",
		}
		c.Data["json"] = res
		c.ServeJSON()
		return
	}
	res := Msg{
		Code: 200,
		Msg:  "登陆成功",
	}
	c.Data["json"] = res
	c.ServeJSON()
}
